/**
 * @file search.h
 * Data structure containing a search.
 */

#ifndef _SEARCH_H
#define _SEARCH_H

#include <glib.h>

#include "addr.h"

typedef struct _Search Search;
typedef struct _Result Result;

Search *search_new();
void search_delete(Search **search);
void search_clear(Search *search);
void search_set(Search *search, uint32_t req_id, const char *file_name);
void search_add(Search *search, const Addr *node, uint32_t file_size);

int _result_cmp(const Result *result1, const Result *result2);

struct _Search {
	uint32_t req_id;
	char file_name[1<<16]; // it's supposed to be P2P_MSG_MAX_DATA_SIZE
	// but if I include msg.h we have a cyclic dependency
	// TODO
	GList *result_list;
};

struct _Result {
	Addr node;
	uint32_t file_size;
};

#endif /* _SEARCH_H */
